﻿(function () {
    var _inited = false;
    var elem = null;
    var _handler = "../Handlers/DocumentInfoHandler.ashx";
    var _foldertree = [];
    var _initelem = '<li class="closed"><span class="folder"><label id="lbLocalPublic">项目盘</label></span>';
    _initelem += '<ul id="LocalPublic" class="treeul" fullpath="" autoid="0" level="1">';
    _initelem += '</ul></li><li class="closed"><span class="searchresult folder">';
    _initelem += '<label id="lbPublicSearchResult" prevKey="" prevPath="">查询结果</label></span></li>';
    var _mode = null;

    function SplitterContainer() {
        $('#splitcontanainer').SplitterContainer({
            panel1: { obj: $('#mainTree'), cssClass: 'treepanel', minWidth: 0 },
            panel2: { obj: $('#ContentPanel'), cssClass: 'contentpanel', minWidth: 0 },
            panel1InitWidth: 245,
            splitterCssClass: 'splitter',
            enableSplitterDblClick: false,
            fixedPanel: 'p1',
            onsplitted: function () { SetGridRange(); }
        });
        $(window).resize(SetGridRange);
    }

    function GetParentNode(folderid) {
        var PrevFolderID = -1;
        if (_foldertree != null) {
            for (var j = 0; j < _foldertree.length; j++) {
                if (_foldertree[j].DeleteFlag == 2) {
                    if (_foldertree[j].AutoID == folderid) {
                        PrevFolderID = _foldertree[j].PrevFolderID;
                        break;
                    }
                }
            }
        }
        return PrevFolderID;
    }

    function UpLevel() {
        var curPath = $("#txtFilePath").val();
        if (curPath == "" || curPath == null) {
            alert("已经是最顶层！"); return;
        }
        var autoid = $("#txtFilePath").attr('autoid');
        var PrevFolderID = GetParentNode(autoid);
        if (PrevFolderID >= 0) {
            $('.filetree').find('span.folder').removeClass('selected');
            $('.filetree').find('ul[autoid=' + PrevFolderID + ']').prev('span').addClass('selected');

            var ilength = curPath.lastIndexOf("\\");
            var fullpath = curPath.substring(0, ilength);
            $("#txtFilePath").val(fullpath).attr('autoid', PrevFolderID);

            GetFolderInfo(PrevFolderID);
        }
    }

    function SwitchShowMode(params) {
        if (params == "Details") {
            $("#ThumbnailListContainer").hide();
            $("#TableListContainer").show();
        } else if (params == "Icon") {
            $("#ThumbnailListContainer").show();
            $("#TableListContainer").hide();
        }
        else {
            if (_mode == "Details") {
                $("#ThumbnailListContainer").show();
                $("#TableListContainer").hide();
                params = "Icon";
            }
            else {
                $("#ThumbnailListContainer").hide();
                $("#TableListContainer").show();
                params = "Details";
            }
        }
        _mode = params;
        SetGridRange();
    }

    function ClearContent() {
        jQuery("#TableList").jqGrid('clearGridData', false);
        jQuery("#ThumbnailList li").remove();
    }

    /*function SetGridRange() {
    var x = $('#mlcontent').width();
    var y = $('#mlcontent').height();
    $('#ThumbnailList').height(y + 'px');
    }*/

    function SetGridRange() {
        var x = $('#mlcontent').width();
        jQuery("#TableList").jqGrid('setGridWidth', x);
        var y = $('#mlcontent').height();
        jQuery("#TableList").jqGrid('setGridHeight', y - 40);
        $('#ThumbnailList').height(y + 'px');
    }

    function GetFolderTree() {
        $('.filetree').empty();
        $('.filetree').append(_initelem);
        $.ajax({
            type: "get",
            url: _handler,
            data: "action=GetFolderTree" + "&ts=" + new Date().valueOf(),
            dataType: 'json',
            success: function (data, textStatus) {
                ProcessAjaxResult(data, textStatus,
                    function (data, textStatus) {
                        _foldertree = data;
                        //BuildFolderTree(data, 1);
                        InitTree();
                    },
                    function (err, textStatus) {
                        alert('操作失败');
                    },
                    this);
            }
        });
    }

    function BuildFolderTree(data, level, previd) {
        var leftData = [];
        if (data && data.length > 0) {
            for (var i = 0; i < data.length; i++) {
                if (data[i].DeleteFlag == 2) {
                    if (data[i].FolderLevel == level && data[i].PrevFolderID == previd) {
                        var ul = $('ul[autoid="' + data[i].PrevFolderID + '"]');
                        var ulpath = ul.attr('fullpath');
                        if (level != 1) {
                            ulpath += "\\";
                        }
                        var li = '<li class="closed">';
                        li += '<span class="folder"><label>';
                        li += data[i].FolderName;
                        li += '</label></span>';
                        li += '<ul class="treeul" fullpath="' + ulpath + data[i].FolderName + '"';
                        li += 'autoid="' + data[i].AutoID + '" level="' + (parseInt(level) + 1) + '"></ul></li>';

                        var b = $(li).appendTo('ul[autoid="' + data[i].PrevFolderID + '"]').data("data", data[i]);
                        //$('ul[autoid="' + data[i].PrevFolderID + '"]').append($(li).data('data', data[i]));
                        $('.filetree').treeview({ add: b });
                    }
                    else {
                        leftData.push(data[i]);
                    }
                }
            }
        }

        /*if (leftData.length > 0) {
        level++;
        BuildFolderTree(leftData, level);
        }*/
    }

    function InitTree() {
        $('.filetree').treeview({
            collapsed: false,
            animated: "medium",
            persist: "location",
            toggle: function () {
                var currentobj = $(this);
                if (!currentobj.is(":hidden")) {
                    //不需要处理折叠事件
                    var ul = currentobj;
                    ul.empty();
                    BuildFolderTree(_foldertree, ul.attr('level'), ul.attr('autoid'));
                }
            },
            nodeclick: function () {
                //var currentPath = $($(this).next()).attr('fullpath');
                var autoid = $(this).attr('autoid');
                if (!autoid) {
                    if ($(this).hasClass('searchresult')) {
                        $('.filetree').find('span.folder').removeClass('selected');
                        $('.filetree').find('span.searchresult').addClass('selected');
                        //$("#ThumbnailList").html("");
                        ClearContent();
                        var prevPath = $("#lbPublicSearchResult").attr("prevPath");
                        var prevKey = $("#lbPublicSearchResult").attr("prevKey");
                        if (prevPath != null && prevPath != '') {
                            GetFolderInfo(prevPath, prevKey);
                        }
                        return;
                    }
                    else {
                        return;
                    }
                }
                $('.filetree').find('span.folder').removeClass('selected');
                $('.filetree').find('ul[autoid=' + autoid + ']').prev('span').addClass('selected');

                var fullpath = $(this).attr('fullpath');
                $("#txtFilePath").val(fullpath).attr('autoid', autoid);
                GetFolderInfo(autoid);
            }
        });
    }

    function GetFolderInfo(folderid, keywords) {
        $(window).trigger('resize');
        if (!keywords) {
            keywords = '';
        }
        top.IndexScript.WaitWindow.Show();
        $.ajax({
            type: "get",
            url: _handler,
            data: "action=GetFolderInfo&Params=" + folderid + "&KeyWord=" + encodeURIComponent(keywords) + "&ts=" + new Date().valueOf(),
            dataType: 'json',
            success: function (data, textStatus) {
                ProcessAjaxResult(data, textStatus,
                    function (data, textStatus) {
                        //$("#ThumbnailList").html("");
                        ClearContent();
                        var icount = 0;
                        //bind folder
                        if (keywords == '' || keywords == null) {
                            var tmpval = $("#txtFilePath").val();
                            if (tmpval == undefined || tmpval == null||tmpval == "") {
                                tmpval = "";
                            }
                            else {
                                tmpval += "\\";
                            }
                            for (var j = 0; j < _foldertree.length; j++) {
                                if (_foldertree[j].DeleteFlag == 2) {
                                    if (_foldertree[j].PrevFolderID == folderid) {

                                        var fp = $('ul[autoid="' + _foldertree[j].AutoID + '"]').attr('fullpath');
                                        if (fp == undefined) {
                                            fp = tmpval + _foldertree[j].FolderName;
                                        }

                                        //bind icon
                                        var li = "<li nt='1' filePath='" + fp + "'";
                                        li += "autoid='" + _foldertree[j].AutoID + "'";
                                        li += "class='Thumbnail_item'><div class='stamp_warper stamp1'";
                                        li += "></div><div class='info_warper' title='";
                                        li += _foldertree[j].FolderName + "'><label class='title_warper'>" + _foldertree[j].FolderName + "</label></div></li>";
                                        $("#ThumbnailList").append(li);

                                        //bind details
                                        icount = j;
                                        var imgelem = "<div class='detail_warper detail1'";
                                        imgelem += " nt='1'";
                                        imgelem += " filePath='" + fp + "'";
                                        imgelem += " autoid='" + _foldertree[j].AutoID + "'></div>";
                                        $("#TableList").jqGrid('addRowData', icount + 1,
            		                    {
            		                        '图标': imgelem,
            		                        '文件名': _foldertree[j].FolderName,
            		                        '扩展名': "",
            		                        '扫描标记': ""
            		                    });
                                    }
                                }
                            }
                        }
                        //bind file
                        if (data != null && data.length > 0) {
                            var contentItemHtmlStr = "";
                            for (var i = 0; i < data.length; i++) {
                                if (data[i].DeleteFlag == 2) {
                                    var li = "<li filePath='" + data[i].FilePath + "' nt='" + GetDocumnetType(data[i].FileExt) + "' ";
                                    li += "autoid='" + data[i].AutoID + "'";
                                    li += "class='Thumbnail_item'><div class='stamp_warper stamp";
                                    li += GetDocumnetType(data[i].FileExt);
                                    if (data[i].OCRFlag == 1) {
                                        li += " ocrflag";
                                    }
                                    li += "' ocrflag='" + data[i].OCRFlag;
                                    li += "'></div><div class='info_warper' title='";
                                    li += data[i].FileName + "'><label class='title_warper'>" + data[i].FileName + "</label></div></li>";
                                    $("#ThumbnailList").append(li);

                                    //set ocrflag
                                    var imgclass = "detail_warper detail" + GetDocumnetType(data[i].FileExt);
                                    if (data[i].OCRFlag == 1) {
                                        imgclass += " ocrflag";
                                    }
                                    var imgelem = "<div class='" + imgclass + "'";
                                    imgelem += " nt='" + GetDocumnetType(data[i].FileExt) + "'";
                                    imgelem += " filePath='" + data[i].FilePath + "'";
                                    imgelem += " fileName='" + data[i].FileName + "'";
                                    imgelem += " autoid='" + data[i].AutoID + "'></div>";

                                    icount++;
                                    //bind details
                                    $("#TableList").jqGrid('addRowData', icount + 1,
            		                {
            		                    '图标': imgelem,
            		                    '文件名': data[i].FileName,
            		                    '扩展名': data[i].FileExt,
            		                    '扫描标记': (data[i].OCRFlag == 1) ? "已扫描" : "未扫描"
            		                });
                                }
                            }
                        }
                    },
                    function (err, textStatus) {
                        alert('操作失败');
                    },
                    this);
            },
            complete: function (data, textStatus) {
                top.IndexScript.WaitWindow.Hide();
            }
        });
    }

    function GetDocumnetType(fileType) {
        var intFileType = 6;
        switch (fileType.toLocaleLowerCase()) {
            case "docx":
                intFileType = 3;
                break;
            case "doc":
                intFileType = 3;
                break;
            case "xls":
                intFileType = 2;
                break;
            case "xlsx":
                intFileType = 2;
                break;
            case "pdf":
                intFileType = 4;
                break;
            case "bmp":
            case "jpg":
            case "gif":
            case "png":
            case "tif":
                intFileType = 5;
                break;
            case "db":
                //去掉Thumbs.db文件
                intFileType = 7;
                break;
            default:
                intFileType = 6;
                break;
        }
        return intFileType;
    }

    function ContentRightMenu() {
        $("#ThumbnailList").contextMenu("RightMenu", {
            bindings: {
                'Download': function () {
                    if (elem == null)
                        return;
                    var fileName = elem.find(".title_warper").html();
                    var filePath = elem.attr("filePath");
                    window.open(_handler + "?action=DownloadFiles&filename=" + fileName + "&filepath=" + encodeURIComponent(filePath));
                },
                'Scan': function () {
                    if (elem.is('li')) {
                        var filePath = elem.attr("filePath");
                        var filetype = elem.attr("nt");
                        var autoid = elem.attr("autoid");
                        if (filetype == "2" || filetype == "3") {
                            var params = { AutoID: autoid, FileType: filetype, FilePath: filePath };
                            params.Language = 1;
                            params.DoBlackWhite = 1;
                            params.DoColorFilter = 1;
                            params.DoNoiseReduce = 1;
                            params.DoExpand = 1;
                            params.Description = '';
                            _OcrDocument(params);
                        }
                        else {
                            top.IndexScript.DocumentOcrDialog.Open({ AutoID: autoid, FileType: filetype, FilePath: filePath }, function (params) {
                                _OcrDocument(params);
                            });
                        }
                    }
                },
                'Check': function () {
                    if (elem.is('li')) {
                        var filePath = elem.attr("filePath");
                        var filetype = elem.attr("nt");
                        var autoid = elem.attr("autoid");
                        _CheckDocument(filePath, filetype, autoid);
                    }
                },
                'CreateFolder': function () {
                    var curPath = $("#txtFilePath").val();
                    if (curPath == "" || curPath == null) {
                        alert("请选择一个文件夹作为创建路径！"); return;
                    }
                    top.IndexScript.CreateFolderDialogControl.Open(curPath, function () {
                        //$("#ThumbnailList").html("");
                        ClearContent();
                        $.ajaxQuest('get', _handler + '?action=GetFileInfo&Params=' + curPath, true, function (result) {
                            if (result != null && result.length > 0) {
                                var contentItemHtmlStr = "";
                                for (var i = 0; i < result.length; i++) {
                                    $("#ThumbnailList").append("<li filePath='" + result[i].FullName + "' nt='" + result[i].NodeType + "' class='Thumbnail_item'><div class='stamp_warper stamp" + result[i].NodeType + "'></div><div class='info_warper' title='" + result[i].NodeName + "'><label class='title_warper'>" + result[i].NodeName + "</label></div></li>")
                                }
                            }
                        });
                    });
                }
            },
            onContextMenu: function (e, args) {
                elem = null;
                $("#RightMenu").find("li").hide();
                elem = $(event.srcElement || event.target);
                if (elem.is("ul")) {
                    $("#CreateFolder").show();
                    return false;
                }
                if (elem.is("li[filePath] *")) {
                    elem = elem.parents("li[filePath]");
                }

                var nt = $(elem).attr("nt");
                if (elem.is("li[filePath]")) {
                    if (nt != "1") {
                        $("#Download").show();
                    }
                    if (nt == "1" || nt == "4" || nt == "5" || nt == "2" || nt == "3") {
                        $("#Scan").show();
                    }
                    $("#Check").show();
                    return true;
                }
                else
                    return false;
            }
        });
        $("#ThumbnailList li[nt='1']").live("dblclick", function () {
            var curPath = $(this).attr('filepath');
            if (curPath == "" || curPath == null) {
                return;
            }
            $("#txtFilePath").val(curPath).attr('autoid', $(this).attr('autoid'));
            $('.filetree').find('span.folder').removeClass('selected');
            $('.filetree').find('ul[autoid=' + $(this).attr('autoid') + ']').prev('span').addClass('selected');
            GetFolderInfo($(this).attr('autoid'));
        });

        $("#ThumbnailList li").live('click', function () {
            $("#ThumbnailList li").removeClass('onlight');
            $(this).addClass('onlight');
        });

        $("#TableList").contextMenu("RightMenu", {
            bindings: {
                'Download': function () {
                    if (elem == null)
                        return;
                    var fileName = elem.attr("fileName");
                    var filePath = elem.attr("filePath");
                    window.open(_handler + "?action=DownloadFiles&filename=" + fileName + "&filepath=" + encodeURIComponent(filePath));
                },
                'Scan': function () {
                    if (elem.is('div')) {
                        var filePath = elem.attr("filePath");
                        var filetype = elem.attr("nt");
                        var autoid = elem.attr("autoid");
                        if (filetype == "2" || filetype == "3") {
                            var params = { AutoID: autoid, FileType: filetype, FilePath: filePath };
                            params.Language = 1;
                            params.DoBlackWhite = 1;
                            params.DoColorFilter = 1;
                            params.DoNoiseReduce = 1;
                            params.DoExpand = 1;
                            params.Description = '';
                            _OcrDocument(params);
                        }
                        else {
                            top.IndexScript.DocumentOcrDialog.Open({ AutoID: autoid, FileType: filetype, FilePath: filePath }, function (params) {
                                _OcrDocument(params);
                            });
                        }
                    }
                },
                'Check': function () {
                    if (elem.is('div')) {
                        var filePath = elem.attr("filePath");
                        var filetype = elem.attr("nt");
                        var autoid = elem.attr("autoid");
                        _CheckDocument(filePath, filetype, autoid);
                    }
                }
            },
            onContextMenu: function (e, args) {
                elem = null;
                $("#RightMenu").find("li").hide();
                elem = $(event.srcElement || event.target);
                if (elem.is("ul")) {
                    $("#CreateFolder").show();
                    return false;
                }
                if (elem.is("tr.ui-row-ltr *")) {
                    elem = elem.parents("tr.ui-row-ltr");
                }

                elem = $(elem).find("div[nt]");
                var nt = $(elem).attr("nt");
                if (elem.is("div[nt]")) {
                    if (nt != "1") {
                        $("#Download").show();
                    }
                    if (nt == "1" || nt == "4" || nt == "5" || nt == "2" || nt == "3") {
                        $("#Scan").show();
                    }
                    $("#Check").show();
                    return true;
                }
                else
                    return false;
            }
        });

        $("#TableList tr.ui-row-ltr").live("dblclick", function (e) {
            var target = $(e.target || e.srcElement);
            if (target.is("tr.ui-row-ltr *")) {
                target = target.parents("tr.ui-row-ltr");
            }
            if (target.is("tr.ui-row-ltr")) {
                var elem = target.find('div[nt]');
                if (elem.attr('nt') == 1) {
                    var curPath = elem.attr('filepath');
                    if (curPath == "" || curPath == null) {
                        return;
                    }
                    var autoid = elem.attr('autoid');
                    $("#txtFilePath").val(curPath).attr('autoid', autoid);
                    $('.filetree').find('span.folder').removeClass('selected');
                    $('.filetree').find('ul[autoid=' + autoid + ']').prev('span').addClass('selected');
                    GetFolderInfo(autoid);
                }
            }
        });

        //有权限才能同步
        $('.btnSync').hide();
        var param = top.IndexScript.getSystemParameter('UserMenuInfo');
        if (param && param != null) {
            for (var i = 0; i < param.length; i++) {
                if (param[i].MenuName == '文档管理') {
                    $('.btnSync').show();
                    break;
                }
            }
        }

        $(".btnUpload").bind("click", function () {
            var curPath = $("#txtFilePath").val();
            if (curPath == "" || curPath == null) {
                alert("请选择一个文件夹作为上传路径！"); return;
            }
            var autoid = $("#txtFilePath").attr('autoid');
            top.IndexScript.UploadFilesDialogControl.Open(curPath, function () {
                GetFolderInfo(autoid);
            });
        });

        $('.btnSync').bind("click", function () {
            var curPath = $("#txtFilePath").val();
            _SyscDocument(curPath);
        });

        $("#TableList").jqGrid({
            datatype: "local",
            colNames: ['图标', '文件名', '扩展名', '扫描标记'],
            colModel: [
            { name: '图标', index: '图标', width: 100, sortable: true, align: 'center' },
            { name: '文件名', index: '文件名', width: 400, sortable: true },
            { name: '扩展名', index: '扩展名', width: 100, sortable: true },
            { name: '扫描标记', index: '扫描标记', width: 100, sortable: true },
            ],
            multiselect: false,
            shrinkToFit: false,
            forceFit: false,
            rowNum: 100000
        });

        $('.btnIconmode').bind("click", function () {
            SwitchShowMode('Icon');
        });

        $('.btnDetailmode').bind("click", function () {
            SwitchShowMode('Details');
        });

        $('.btnSwithmode').bind('click', function () {
            SwitchShowMode();
        });

        $('.btnUplevel').bind('click', function () {
            UpLevel();
        });

        $("#btnFullTextSearch").bind("click", function () {
            var curPath = $("#txtFilePath").val();
            if (curPath == "" || curPath == null) {
                alert("请选择一个文件夹作为检索路径！"); return;
            }
            if ($.trim($("#txtFullTextSearch").val()) == "") {
                alert("请输入关键字！"); return;
            }
            var autoid = $("#txtFilePath").attr('autoid');
            var SearchKey = $("#txtFullTextSearch").val();
            $("#lbPublicSearchResult").attr("prevPath", autoid);
            $("#lbPublicSearchResult").attr("prevKey", SearchKey);
            GetFolderInfo(autoid, SearchKey);
            $("#txtFilePath").val('');
            $("#txtFilePath").removeAttr('autoid');
            $('.filetree').find('span.folder').removeClass('selected');
            $('.filetree').find('span.searchresult').addClass('selected');
        });

        SwitchShowMode('Icon');

        /*$("#lbPublicSearchResult").bind("click", function () {
        var prevPath = $(this).attr("prevPath");
        if (prevPath == null || prevPath == "") {
        return;
        }
        var prevKey = $(this).attr("prevKey");
        if (prevKey == null || prevKey == "") {
        return;
        }
        $.ajaxQuest('get', _handler + '?action=SearchFiles&Params=' + prevPath + "&KeyWord=" + prevKey, true, function (result) {
        $("#ThumbnailList").html("");
        if (result != null && result.length > 0) {
        for (var i = 0; i < result.length; i++) {
        $("#ThumbnailList").append("<li filePath='" + result[i].FullName + "' nt='" + result[i].NodeType + "' class='Thumbnail_item'><div class='stamp_warper stamp" + result[i].NodeType + "'></div><div class='info_warper' title='" + result[i].NodeName + "'><label class='title_warper'>" + result[i].NodeName + "</label></div></li>")
        }
        }
        else {
        alert("搜索结果为空！"); return;
        }
        });
        });*/
    }

    function _SyscDocument(params) {
        top.IndexScript.WaitWindow.Show();
        $.ajax({
            type: "post",
            url: _handler,
            data: "action=SyscDocumentInfo&Params=" + encodeURIComponent($.toJSON(params)),
            dataType: 'json',
            success: function (data, textStatus) {
                top.IndexScript.WaitWindow.Hide();
                ProcessAjaxResult(data, textStatus,
                    function (data, textStatus) {
                        alert('同步成功');
                    },
                    function (err, textStatus) {
                        alert('操作失败');
                    },
                    this);
                //刷新当前页面
                window.location.reload();
            }
        });
    }

    function _CheckDocument(filePath, filetype, autoid) {
        $.ajax({
            type: "post",
            url: _handler,
            data: "action=CheckDocumentInfo&FilePath=" + encodeURIComponent(filePath) + "&FileType=" + filetype,
            dataType: 'json',
            /*async: false,*/
            success: function (data, textStatus) {
                ProcessAjaxResult(data, textStatus,
                    function (data, textStatus) {
                        if (data) {
                            if (filetype == 1) {
                                alert('文件夹存在');
                            }
                            else {
                                alert('文档存在');
                            }
                        }
                        else {
                            if (filetype == 1) {
                                if (confirm('文件夹不存在，是否删除？')) {
                                    _DeleteDocument(filetype, autoid);
                                }
                            }
                            else {
                                if (confirm('文档不存在，是否删除？')) {
                                    _DeleteDocument(filetype, autoid);
                                }
                            }
                        }
                    },
                    function (err, textStatus) {
                        alert('操作失败');
                    },
                    this);
            }
        });
    }

    function _DeleteDocument(filetype, autoid) {
        $.ajax({
            type: "post",
            url: _handler,
            data: "action=DeleteDocumentInfo&FileType=" + filetype + "&AutoID=" + autoid,
            dataType: 'json',
            success: function (data, textStatus) {
                ProcessAjaxResult(data, textStatus,
                    function (data, textStatus) {
                        alert('删除成功');
                        /*var fid = $("#txtFilePath").attr('autoid');
                        if (fid) {
                        //当前文件夹
                        GetFolderInfo(fid);
                        }
                        else*/
                        {
                            //搜索结果
                            $("#ThumbnailList >li[autoid='" + autoid + "'][nt='" + filetype + "']").remove();
                        }

                        if (filetype == 1) {
                            //bind folder tree;
                            GetFolderTree();
                        }
                    },
                    function (err, textStatus) {
                        alert('操作失败');
                    },
                    this);
            }
        });
    }

    function _handlerMsg(msg) {
        switch (msg) {
            case 0:
                alert('OCR扫描成功');
                break;
            default:
                alert('操作失败');
                break;
        }
    }

    function _OcrDocument(params) {
        $.ajax({
            type: "post",
            url: _handler,
            data: "action=OcrDocumentInfo&Params=" + encodeURIComponent($.toJSON(params)),
            dataType: 'json',
            success: function (data, textStatus) {
                ProcessAjaxResult(data, textStatus,
                    function (data, textStatus) {
                        _handlerMsg(data);
                    },
                    function (err, textStatus) {
                        alert('操作失败');
                    },
                    this);
            }
        });
    }

    this.DocumentInfoMgr = {
        init:
        function () {
            if (!!_inited) return;
            //bind frame
            SplitterContainer();

            //bind right menu
            ContentRightMenu();

            //bind folder tree;
            GetFolderTree();

            _inited = true;
        }
    }
})();
$(function () {
    DocumentInfoMgr.init();
});